

<%content_for 'sidebar' do%>
	<div id="reservation_sidebar" style="position:absolute">
		<%= render_component(:controller => 'schedule', :action => 'quickpick')%>
	</div>
	<div style="height:500px"></div>
	
<% end %>

<script type="text/javascript">
      function autoposition_reservation_sidebar(){
         sc = getPageScroll()
         $("reservation_sidebar").style.top = "160px";
         if(sc[1]>160){
             $("reservation_sidebar").style.top = sc[1]+"px";                    
         }
      }

     if (window.addEventListener) {
         window.addEventListener("scroll", function (e) { autoposition_reservation_sidebar(); }, false);
     } else if (window.attachEvent) {
         window.attachEvent('on' + "scroll", function (e) { autoposition_reservation_sidebar(); });
     }
 </script>


<table  width="100%" id="reservation_table">


<tr><th>Date/Time</th><th>Student</th><th>Aircraft</th></tr>

<% if @reservations.size == 0 %>
<tr><td>No Upcoming Reservations.</td></tr>	
<% end %>
	<% @reservations.each{|reservation| %>
		<% if reservation.nil? then next end %>
	<tr>
	<td style="">
	<% expired = reservation.time_end<Time.now %>
	<table><tr><td>		
    <div style="border: 1px solid black; height:10px;width:10px; background:<%=expired ? 'black' : (reservation.status=='approved' ? 'lightgreen' : (reservation.status=='canceled' ? '#f2a3a0' : '#eeee00'))%>;"> </div>
	</td>
	<td>
	   <a href="#" onclick="new Ajax.Updater('reservation_sidebar', '/reservation/edit?id=<%= reservation.id %>', {asynchronous:true, evalScripts:true,parameters:'return_to='+escape('<%= request.env['REQUEST_URI'] %>')})">
		<% if reservation.time_start.to_date == reservation.time_end.to_date %>
	   		<%= reservation.time_start.strftime("%a&nbsp;%b&nbsp;%d, %I%p")%>-<%= reservation.time_end.strftime("%I%p") %>
		<% else  %>
   			<%= reservation.time_start.strftime("%a&nbsp;%b&nbsp;%d, %I%p")%>-<%= reservation.time_end.strftime("%a&nbsp;%b&nbsp;%d, %I%p") %>
		<% end %>
	   </a>
	</td></tr></table>
</td>
	<td>
		<% pilot = reservation.pilot%>
		   <% if not pilot.nil?%>
		       <%= pilot.short_name%>
		   <% end %>
	</td>
	<td>
		<% aircraft = reservation.aircraft%>
		   <% if not aircraft.nil?%>
		       <%= aircraft.type_and_identifier%>
		   <% end %>
	</td>
</tr>
<% } %>
<tr><th colspan="3"></th></tr>

</table>

<div class="pagination_links">
    <%= link_to 'Older Reservations', { :user=>params[:user],:offset => ((@before-50)>0 ? @before-50:0)} if @before>0 %> 
    <%= link_to 'Newer Reservations', {:user=>params[:user],:offset => (@before+50) } if @after>50 %>
</div>

<div style="padding-left:80px">
<table cellspacing="10px"><tr>
<td style="text-align:center;width:100px"><div style="padding-top:5px;display:marker; height:30px;  background: lightgreen;"><label style="color:#001b57">Approved</label></div></td>
<td style="text-align:center;width:100px"><div style="padding-top:5px;display:marker; height:30px; background: #eeee00;"><label style="color:#001b57">Awaiting Approval</label></div></td>
<td style="text-align:center;width:100px"><div style="padding-top:5px;display:marker; height:30px; background: #f2a3a0;"><label style="color:#001b57">Cancelled</label></div></td>
<td style="text-align:center;width:100px"><div style="padding-top:5px;display:marker; height:30px; background: black;"><label style="color:#71b4d0">Expired</label></div></td>
</tr></table>
</div>

<script type="text/javascript">color_table('reservation_table')</script>